<div class="bjui-pageHeader">
    <form id="pagerForm" data-toggle="ajaxsearch" action="${request.getContextPath()}/ProcessState/processState" method="post">
        <div class="bjui-searchBar">
            <g:hiddenField name="SYS_QUERY_NAME" value="processState" />
            <g:hiddenField name="EXPORT_CONTENT_NAME" value="Excel" />
            %{--工序状态分析--}%
            <label >工序编码：</label>&nbsp;
            <input type="text" name="stepName" value="${stepName}"/>
            <label >订单号：</label>&nbsp;
            <input type="text" name="startDocId" placeholder="FROM" value="${startDocId}"/>
            <input type="text" name="endDocId" placeholder="TO" value="${endDocId}"/>


            <label >产品编码：</label>&nbsp;
            <input type="text" name="partName" value="${partName}"/>
            <label >图号：</label>&nbsp;
            <input type="text" name="tuhao" value="${tuhao}"/>
            <button type="submit" class="btn-default" data-icon="search">查询</button>&nbsp;
            <button type="button" class="btn-blue" onclick="javascript:bjuiExportExl('#pagerForm','${request.getContextPath()}/ProcessState/exportExcel')" data-icon="file-excel-o" title="导出Excel">导出</button>&nbsp;
        </div>
    </form>
</div>

<div class="bjui-pageContent">
    <g:if test="${processState.size() > 0}">
        <table  data-toggle="tablefixed" data-width="100%" data-nowrap="true">
            <thead>
            <tr id="t1">
                <g:each in="${tableHeadList}" status="j" var="headInstance">
                    <g:if test="${headInstance!='RN'}">
                        <th  width="125"><g:message code="${headInstance}" default="${headInstance}"/></th>
                    </g:if>
                </g:each>
            </tr>
            </thead>
            <tbody>
            <g:if test="${processState.size()>0}">
                <g:each in="${processState}" status="i" var="dataInstance">
                    <tr>
                        <g:each in="${tableHeadList}" status="j" var="headInstance">
                            <g:if test="${headInstance=='STEP_NAME'}">
                                <td>
                                    <a href="${request.getContextPath()}/ProcessState/processStateTwo?stepName=<%=dataInstance.STEP_NAME%>&state=<%=headInstance%>" data-toggle="navtab"  data-id="dialog-normal" data-options="{id:'processStateTwo', title:'工序状态分析表二阶'}">${dataInstance["${headInstance}"] }</a>
                                </td>
                            </g:if>
                            <g:elseif test="${headInstance=='WAIT1'}">
                                <td name="progressWait${i+1}">
                                    ${dataInstance["${headInstance}"] }
                                </td>
                            </g:elseif>
                            <g:elseif test="${headInstance=='RUN'}">
                                <td name="progressRun${i+1}">
                                    ${dataInstance["${headInstance}"] }
                                </td>
                            </g:elseif>
                            <g:elseif test="${headInstance=='REWORK_QTY'}">
                                <td name="progressRework${i+1}">
                                    ${dataInstance["${headInstance}"] }
                                </td>
                            </g:elseif>
                            <g:elseif test="${headInstance=='OS_QTY'}">
                                <td name="progressOrc${i+1}">
                                    ${dataInstance["${headInstance}"] }
                                </td>
                            </g:elseif>
                            <g:elseif test="${headInstance=='SCRAP_QTY'}">
                                <td name="progressScrap${i+1}">
                                    ${dataInstance["${headInstance}"] }
                                </td>
                            </g:elseif>
                            <g:elseif test="${headInstance!='RN'}">
                                <td>${dataInstance["${headInstance}"]}</td>
                            </g:elseif>
                        </g:each>
                    </tr>
                </g:each>
                <tr>

                    <td colspan="2">小计</td>
                    <td id="waitShow"></td>
                    <td id="runShow"></td>
                    <td id="reworkShow"></td>
                    <td id="orcShow"></td>
                    <td id="scrapShow"></td>

                </tr>
                <tr>

                    <td colspan="2">合计</td>
                    <td>${processStateSumQty[0].SUM_WAIT1}</td>
                    <td>${processStateSumQty[0].SUM_RUN}</td>
                    <td>${processStateSumQty[0].SUM_REWORK_QTY}</td>
                    <td>${processStateSumQty[0].SUM_OS_QTY}</td>
                    <td>${processStateSumQty[0].SUM_SCRAP_QTY}</td>
                </tr>

            </g:if>
            <g:else>
                <g:render template="../template/emptyPanel" />
            </g:else>
            </tbody>
        </table>
    </g:if>
</div>
<g:render template="../template/pagination" />

<script>
    $(function(){
        /*获取当页等待数量的小计*/
        var progressN=0
        var progressR=0
        var progressReww=0
        var progressO=0
        var progressS=0
        for(var i=1;i<=${processState.size()};i++){
            var progressNo='progressWait'+i
            var progressNor=$("td[name='"+progressNo+"']").text()==''?0:parseInt($("td[name='"+progressNo+"']").text());
            progressN+=progressNor

            var progressRe='progressRun'+i
            var progressRun=$("td[name='"+progressRe+"']").text()==''?0:parseInt($("td[name='"+progressRe+"']").text());
            progressR+=progressRun

            var progressRe='progressRework'+i
            var progressRew=$("td[name='"+progressRe+"']").text()==''?0:parseInt($("td[name='"+progressRe+"']").text());
            progressReww+=progressRew

            var progressOr='progressOrc'+i
            var progressOrc=$("td[name='"+progressOr+"']").text()==''?0:parseInt($("td[name='"+progressOr+"']").text());
            progressO+=progressOrc

            var progressSc='progressScrap'+i
            var progressScr=$("td[name='"+progressSc+"']").text()==''?0:parseInt($("td[name='"+progressSc+"']").text());
            progressS+=progressScr
        }
        $("#waitShow").html(progressN);
        $("#runShow").html(progressR);
        $("#reworkShow").html(progressReww);
        $("#orcShow").html(progressO);
        $("#scrapShow").html(progressS);
    })
</script>

